#ifndef __STEP_MOTOR_H
#define __STEP_MOTOR_H

#include <math.h>

#include "user_serial.h"
#include "Emm_V5.h"

#define STEP_MOTOR_DELAY(time) vTaskDelay(time)
#define STEP_MOTOR_BUFFER serial_bufferRobotArm()

#define STEP_MOTOR_STEPNUM 200.000f // (360/1.8)
#define STEP_MOTOR_SUBDIVISION 16.000f
#define STEP_MOTOR_DELAY_TIME 2
#define STEP_MOTOR_ACCELERATED 200

void stepMotor_init(void);
void stepMotor_setSpeed(uint8_t addr,uint8_t dir, uint16_t val);
void stepMotor_clearZero(uint8_t addr);
void stepMotor_power(uint8_t addr, uint8_t state);
float map(float input, float in_min, float in_max, float out_min, float out_max);
void stepMotor_setAngle(uint8_t addr, float angle, uint16_t speed);
void stepMotor_circle(uint8_t addr, float angle, uint16_t speed);
float stepMotor_cmdToAngle(uint8_t *data);
float stepMotor_getAngle(uint8_t addr);
void stepMotor_setAngle_time(uint8_t addr, float angle, uint16_t tim);
void stepMotor_circle_time(uint8_t addr, float angle, uint16_t tim);

#endif
